﻿using oueb;
using oueb.mod;
using System.Text;

namespace ConsoleApp1
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello, World!");
            var test_path = @"oueb.dll";
            var s = new OuebServer("http://127.0.0.1:1000");
            s.UseCorsNoLimit();
            s.AddRoute(new OptionsModule());
            s.AddRoute("/shutdown", async c =>
            {
                await c.Response.WriteTextAsync("ok");
                s.Shutdown();
                return true;
            });
            s.AddRoute(null, async c =>
            {
                await c.Request.AcceptFormData();
                if (c.Request.Files.Count > 0) Console.WriteLine(c.Request.Files[0].Filename);
                await c.Response.WriteTextAsync("test");
                return true;
            });

            lock (s.Listen()) {
                Console.WriteLine(string.Join("\n", s.Uris.Select(t=> t.ToString())));
                while (s.Runing) Monitor.Wait(s, 500);
            }
            Console.WriteLine("Bye");
        }
    }
}
